<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<%@ page import="cs236369.hw5.DBConnection" %>
	<%@ page import="cs236369.hw5.Team" %>
	<%@ page import="cs236369.hw5.Post" %>
	<%@ page import="cs236369.hw5.User" %>
	<%@ page import="java.util.ArrayList" %>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
	<%@ page import="cs236369.hw5.InitListener" %>
	<title>My Posts</title>
	
	<!-- initialize google maps scripts and what to load -->
	<script src="googleMapScripts.js" type="text/javascript"></script>
	<script> 
		googleMapScripts_loadTasks=false;		
		googleMapScripts_loadTeams=false;		
		googleMapScripts_loadMatches=false;
		googleMapScripts_loadUserPosts=true;
	</script>
</head>
<body>
	<%	String name = (String)session.getAttribute("name");
		String username = (String)session.getAttribute("userName");
		if(name == null || username == null) {
			response.setStatus(403);
			response.sendRedirect(request.getContextPath() + InitListener.welcomePage);
			return;
		}
		ArrayList<Post> teams = DBConnection.getAllTeams(username);
		ArrayList<Post> tasks = DBConnection.getAllMissions(username);	%>
	<p class="title">My posts</p>
	<p class="subtitle">Posts on a map</p>
	<div id="map-canvas" class="map-canvas"></div>
	<div><p class="subtitle">Posts in a list</p>
	<p class="topic">Teams:<br/>
	Click on a team to open the team's page</p>
		<p class="text">
			<%	for(Post post : teams) {
					out.print("<label onclick=\"loadToMainContent(\'team.jsp?postId=" +
							post.getId() + "\')\">id " + post.getId() + ": " + post.getName() + "</label><br />\n");
				}	%>
		</p><br />
	<p class="topic">Tasks:<br />
	Click on a task to open the task's page</p>
		<p class="text">
			<%	for(Post post : tasks) {
					out.print("<label onclick=\"loadToMainContent(\'task.jsp?postId=" +
							post.getId() + "\')\">id " + post.getId() + ": " + post.getName() + "</label><br />\n");
				}	%>
		</p></div>
</body>
</html>
